package com.yanfan.zutai.controller;

import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.zutai.aop.SysInitData;
import com.yanfan.zutai.aop.SysInitUpdateData;
import com.yanfan.zutai.aop.SysQueryData;
import com.yanfan.zutai.domain.BDevicePhone;
import com.yanfan.zutai.service.IBDevicePhoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 短信报警电话Controller
 *
 * @author ruoyi
 * @date 2021-09-15
 */
@RestController
@RequestMapping("/zutai/bDevicePhone")
public class BDevicePhoneController extends BaseController {
    @Autowired
    private IBDevicePhoneService bDevicePhoneService;

    /**
     * 查询短信报警电话列表
     */
//    //@PreAuthorize("@ss.hasPermi('bDevicePhone:list')")
    @GetMapping("/list")
    //@SysQueryData
    public TableDataInfo list(BDevicePhone bDevicePhone) {
        startPage();
        List<BDevicePhone> list = bDevicePhoneService.selectBDevicePhoneList(bDevicePhone);
        return getDataTable(list);
    }

    /**
     * 导出短信报警电话列表
     */
//    //@PreAuthorize("@ss.hasPermi('bDevicePhone:export')")
    @Log(title = "短信报警电话", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @SysQueryData
    public AjaxResult export(BDevicePhone bDevicePhone) {
        List<BDevicePhone> list = bDevicePhoneService.selectBDevicePhoneList(bDevicePhone);
        ExcelUtil<BDevicePhone> util = new ExcelUtil<BDevicePhone>(BDevicePhone.class);
        return util.exportExcel(list, "bDevicePhone");
    }

    /**
     * 获取短信报警电话详细信息
     */
//    //@PreAuthorize("@ss.hasPermi('bDevicePhone:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(bDevicePhoneService.selectBDevicePhoneById(id));
    }

    /**
     * 新增短信报警电话
     */
//    //@PreAuthorize("@ss.hasPermi('bDevicePhone:add')")
    @Log(title = "短信报警电话", businessType = BusinessType.INSERT)
    @PostMapping
    @SysInitData
    public AjaxResult add(@RequestBody BDevicePhone bDevicePhone) {
        return toAjax(bDevicePhoneService.insertBDevicePhone(bDevicePhone));
    }

    /**
     * 修改短信报警电话
     */
//    //@PreAuthorize("@ss.hasPermi('bDevicePhone:edit')")
    @Log(title = "短信报警电话", businessType = BusinessType.UPDATE)
    @PutMapping
    @SysInitUpdateData
    public AjaxResult edit(@RequestBody BDevicePhone bDevicePhone) {
        return toAjax(bDevicePhoneService.updateBDevicePhone(bDevicePhone));
    }

    /**
     * 删除短信报警电话
     */
//    //@PreAuthorize("@ss.hasPermi('bDevicePhone:remove')")
    @Log(title = "短信报警电话", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bDevicePhoneService.deleteBDevicePhoneByIds(ids));
    }
}
